package com.kw.auth.phone;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * Created by fp295 on 2018/11/25.
 * 手机验证码token
 */
public class PhoneAuthenticationToken extends AbstractAuthenticationToken {

    protected final Object principal;
    protected Object credentials;

    public PhoneAuthenticationToken(String mobile, String credentials) {
        super(null);
        this.principal = mobile;
        this.credentials = credentials;
        setAuthenticated(false);

    }

    public PhoneAuthenticationToken(Object principal, String credentials
                                   , Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
        this.principal = principal;
        this.credentials = credentials;
    }


    @Override
    public Object getCredentials() {
        return this.credentials;
    }

    @Override
    public Object getPrincipal() {
        return this.principal;
    }
}
